#include <bits/stdc++.h>
#define Fill(a, b) memset(a, b, sizeof(a))
using namespace std;

const int maxn = 150, maxr = 20;
int G[maxn][5], deg[maxn], D[maxn][maxn][maxn];
int s[3], g[3];
int C, R, N, cnt;


int dx[] = {0, 1, -1, 0, 0};
int dy[] = {0, 0, 0, 1, -1};

int inline ID(int a, int b, int c){
    return a<<16 | b<<8 | c;
}

bool inline conflic(int a, int a2, int b, int b2){
    return (a2 == b && b2 == a) || a2 == b2;
}

int bfs() {
    queue<int> q;
    q.push(ID(s[0], s[1], s[2]));
    Fill(D, -1);
    D[s[0]][s[1]][s[2]] = 0;
    while(!q.empty()){
        int t = q.front(); q.pop();
        int a = t>>16 & 0xFF, b = t>>8 & 0xFF, c = t & 0xFF;
        if(a==g[0] && b==g[1] && c==g[2]) return D[a][b][c];
        for (int i = 0; i < deg[a]; ++i) {
            int na = G[a][i];
            for (int j = 0; j < deg[b]; ++j) {
                int nb = G[b][j];
                if(conflic(a, na, b, nb)) continue;
                for (int k = 0; k < deg[c]; ++k) {
                   int nc = G[c][k];
                   if(conflic(a, na, c, nc)) continue;
                   if(conflic(b, nb, c, nc)) continue;

                   if(D[na][nb][nc] >= 0) continue;
                   D[na][nb][nc] = D[a][b][c] + 1;
                   q.push(ID(na, nb, nc));
                }
            }
        }
    }
    return -1;
}

void init() {
    Fill(G, 1);
    Fill(D, 0);
}

int main() {
    //ios_base::sync_with_stdio(false); cin.tie(nullptr);
    int T = 0;
    while (cin >> C >> R >> N && C) {
        cin.get();
        init();

        cnt = 0;
        int x[maxn], y[maxn], id[maxr][maxr];
        Fill(id, -1); Fill(x, 0); Fill(y, 0);
        for (int i = 1; i <= R; ++i) {
            string in;
            getline(cin, in);
            for (int j = 1; j <= in.size(); ++j) {
                char c = in[j - 1];
                if (c == '#') continue;

                x[cnt] = i; y[cnt] = j;
                id[i][j] = cnt;
                if (islower(c))  s[c-'a'] = cnt;
                if (isupper(c))  g[c-'A'] = cnt;
                ++cnt;
            }
        }

        for (int i = 0; i < cnt; ++i) {
            deg[i] = 0;
            for (int dir = 0; dir < 5; ++dir) {
                int x1 = x[i], y1 = y[i];
                int x2 = x1 + dx[dir], y2 = y1 + dy[dir];
                int i2 = id[x2][y2];
                if(i2 < 0) continue;
                G[i][deg[i]++] = i2;
            }
        }

        if(N<=2) {deg[cnt] = 1; G[cnt][0] = cnt; s[2] = g[2] = cnt; ++cnt;}
        if(N<=1) {deg[cnt] = 1; G[cnt][0] = cnt; s[1] = g[1] = cnt; ++cnt;}

        cout << bfs() << "\n";
    }
    return 0;
}